//package com.lagou.config;
//
//import com.lagou.service.MyRestTemplateHeaderModifierInterceptor;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.http.client.ClientHttpRequestInterceptor;
//import org.springframework.util.CollectionUtils;
//import org.springframework.web.client.RestTemplate;
//
//import javax.annotation.Resource;
//import java.util.ArrayList;
//import java.util.List;
//
////@Configuration
//public class RestTemplateConfig {
//
////    @Resource
//    private MyRestTemplateHeaderModifierInterceptor myRestTemplateHeaderModifierInterceptor;
//
//    // 都是默认的配置
////    @Bean
//    public RestTemplate restTemplate() {
//        return new RestTemplate();
//    }
//
//    // 追加了自定义的interceptor的bean对象
////    @Bean
////    @Qualifier(value = "restTemplateInterceptor")
//    public RestTemplate restTemplateInterceptor() {
//        RestTemplate restTemplate = new RestTemplate();
//
//        List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors();
//        if (CollectionUtils.isEmpty(interceptors)) {
//            interceptors = new ArrayList<>();
//        }
//        interceptors.add(myRestTemplateHeaderModifierInterceptor);
//        restTemplate.setInterceptors(interceptors);
//
//        return restTemplate;
//    }
//}
